//
//  SDuanziTableViewCell.m
//  News
//
//  Created by dlios on 15-5-14.
//  Copyright (c) 2015年 PEAK. All rights reserved.
//

#import "SDuanziTableViewCell.h"

@interface SDuanziTableViewCell ()

@end

@implementation SDuanziTableViewCell
- (void)dealloc
{
    [_lable release];
    [_button1 release];
    [_button2 release];
    [_img release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.lable = [[UILabel alloc] init];
        _lable.numberOfLines = 0;
        _lable.font = [UIFont systemFontOfSize:17];
        [self.contentView addSubview:_lable];
        [_lable release];
        self.img = [[UIImageView alloc] init];
        [self.contentView addSubview:_img];
        [_img release];
        
  
        

    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];

    
    CGFloat f = [[self class]heightWithText:_lable.text];
    _lable.frame = CGRectMake(10, 0, self.contentView.frame.size.width  - 20, f );
    _img.frame = CGRectMake(10,_lable.frame.size.height + 10, self.contentView.frame.size.width - 20, [UIScreen mainScreen].bounds.size.height / 2.5);

   
    
}


+(CGFloat)heightWithText:(NSString *)text
{
    NSDictionary *dic = @{NSFontAttributeName :[UIFont systemFontOfSize:17]};
    CGSize size = CGSizeMake(375, 1000);
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}
-(void)setShappy:(SHppyObject *)Shappy
{
    if (_Shappy != Shappy) {
        [_Shappy release];
        _Shappy = [Shappy retain];
    }
    _lable.text = Shappy.digest;
    [_img sd_setImageWithURL:[NSURL URLWithString:Shappy.imgsrc]placeholderImage:[UIImage imageNamed:@"``_3(NZ4U{L@4L7FN0J70DA"]];
    

}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
